package com.ten.order.factory;

import com.ten.common.core.vo.Result;
import com.ten.order.feign.CourseListFeign;
import feign.hystrix.FallbackFactory;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;

/**
 * @author ：张成（3092211427@qq.com）
 * @date ：Created in 2022/12/21 15:06
 * @description： 用于远程调用服务异常时，对异常作出处理
 * @modified By：
 * @version:
 */
@Component
@Slf4j
public class CourseListFeignFactory implements FallbackFactory<CourseListFeign> {
    @Override
    public CourseListFeign create(Throwable throwable) {
        return courseId -> {
            log.error("课程微服务故障" + throwable.getMessage());
            return new Result<>(500, "课程微服务故障");
        };
    }
}
